<?php
  /*
  	替换提交内的明感字符
  	replace unsafe characaters
  	用法: Post_Get_Fix(替换内容)
  	example:Post_Get_Fix(content)
  	,"/","&#47;"
  */
  function Post_Get_Fix($msg){
		$array1 = array('&','\"',"\'",'"',"'",'\\');
		$array2 = array('&amp;','&quot;','&#39;','&quot;','&#39;','&#92;');
		$msg = str_replace($array1,$array2,$msg);
	return $msg;
  }

  //msg表示需要还原过滤的内容,br为1表示是对内容换行
  //example:msg represents the content that needs revert to original status,br for 1 represents newline.
  //'&lt;','&gt;',
  //'<','>',
  
	function HTML_Fix($msg,$br=1){
		$array1 = array('&#92;','&amp;','&quot;','&#39;','<?','?>');
		$array2 = array('\\','&','"',"'",'&lt;?','?&gt;');
		$msg = str_replace($array1,$array2,$msg);
		return $msg;
	}
	
	
	//安全数据处理
	foreach($_POST as $Key=>$Value){ $$Key = Post_Get_Fix($_POST["$Key"]);}
	unset($Key,$Value);
	foreach($_GET as $Key=>$Value){ $$Key = Post_Get_Fix($_GET["$Key"]);}
	
	
	/**
	*  获取当前页面地址
	*/
	function geturl() {
		return 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['SCRIPT_NAME'] . '?' . $_SERVER['QUERY_STRING'];
	}
	
	
?>